require('telescope').setup({
    defaults = {
        mappings = {
            n = {
                ["?"] = require('telescope.actions.generate').which_key {
                    name_width = 20,           -- typically leads to smaller floats
                    max_height = 0.5,          -- increase potential maximum height
                    separator = " > ",         -- change sep between mode, keybind, and name
                    close_with_action = false, -- do not close float on action
                },
            },
        },
        layout_strategy = 'vertical',
        -- layout_strategy = 'horizontal',
        layout_config = {
            vertical = { width = 0.8 },
            preview_cutoff = 1,
            -- other layout configuration here
        },
        -- other defaults configuration here
        path_display = { shorten = 1 }
    },
    -- other configuration values here
    pickers = {
        find_files = {
            theme = "dropdown",
            previewer = true,
        },
    },
    extensions = {
        cmdline = {
            -- Adjust telescope picker size and layout
            picker   = {
                -- layout_config = {
                --     width  = 120,
                --     height = 25,
                -- }
            },
            -- Adjust your mappings
            mappings = {
                complete      = '<Tab>',
                run_selection = '<C-CR>',
                run_input     = '<CR>',
            },
            -- Triggers any shell command using overseer.nvim (`:!`)
            overseer = {
                enabled = true,
            },
        },
        media_files = {
            -- filetypes whitelist
            -- defaults to {"png", "jpg", "mp4", "webm", "pdf"}
            filetypes = { "png", "webp", "jpg", "jpeg" },
            -- find command (defaults to `fd`)
            find_cmd = "rg"
        }
    }
})

local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true, nowait = true }


map('n', '<C-x>t', '<cmd>Telescope live_grep<CR>', opts)
map('n', '<C-x>/', '<cmd>Telescope current_buffer_fuzzy_find<CR>', opts)
map('n', '<C-x>?', '<cmd>Telescope live_grep<CR>', opts)
map('n', '<C-x>q', '<cmd>Telescope quickfix<CR>', opts)
map('n', '<C-x>b', '<cmd>ls<CR><cmd>Telescope buffers<CR>', opts)
map('n', '<C-x>f', '<cmd>Telescope fd<CR>', opts)
map('n', '<C-x><C-f>', '<cmd>Telescope find_files<CR>', opts)
map('n', '<C-x>g', '<cmd>Telescope git_status<CR>', opts)
map('n', '<C-x>j', '<cmd>Telescope jumplist<CR>', opts)
map('n', '<C-x>c', '<cmd>Telescope commands<CR>', opts)
map('n', '<C-x>h', '<cmd>Telescope command_history<CR>', opts)
-- map('n', '<C-q>', '<cmd>Telescope find_files prompt_prefix=🔍 <CR>', opts)
map('n', '<M-x>', '<cmd>Telescope<CR>', opts)

require('telescope').load_extension('codecompanion')
map('n', '<c-x>d', '<cmd>Telescope codecompanion<CR>', opts)

require("telescope").load_extension('cmdline')
map('n', '<C-x>;', ':Telescope cmdline<CR>', { noremap = true, desc = "Cmdline" })
map('n', '<C-x>!', ':Telescope cmdline<CR>!', { noremap = true, desc = "Cmdline" })

require('telescope').load_extension('media_files')

